<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:insert name="contentFields">
	<h:outputLabel class="rub1" value="Logga in/ut"></h:outputLabel>
	<br/> <br/>
</ui:insert>

<ui:insert name="formFields">
	<f:view>
		<h:panelGroup id="loginForm" rendered="#{!loginBean.loggedin}">
		<h:outputLabel value="Logga in för att kunna handla."></h:outputLabel>
			<h:form>
				<h:panelGrid columns="2">
	      			<h:outputLabel value="Anvnamn " ></h:outputLabel>
    	  			<h:inputText  value="#{loginBean.username}"></h:inputText>
    	  		</h:panelGrid>
    	  		<h:panelGrid columns="2">
					<h:outputLabel value="Losenord " ></h:outputLabel>
					<h:inputSecret  value="#{loginBean.triedPwd}"></h:inputSecret>
				</h:panelGrid>
				<h:commandButton actionListener="#{loginBean.login}" value="Logga in"></h:commandButton>
			</h:form>
		</h:panelGroup>
		
		<h:panelGroup id="logoutButtonForm" rendered="#{loginBean.loggedin}">
			<h:form>
				<h:outputLabel value="Du är inloggad."></h:outputLabel>
				<h:commandButton action="#{loginBean.logout()}" value="Logga ut"></h:commandButton>
			</h:form>
		</h:panelGroup>
		
		<br/><br/>
		<h:panelGroup id="adminFunctions" rendered="#{loginBean.admin}">
		
			<h:panelGrid>
			<h:form>
				<h:outputLabel value="Ta bort produkt " ></h:outputLabel>
				<h:selectOneMenu value="#{adminBean.selectedProduct}">				
				<f:selectItems value="#{adminBean.productFromList}" />
   				</h:selectOneMenu>	   		
				<h:commandButton value="Ta bort" actionListener="#{adminBean.uppdateDBproduct}" />
			</h:form>
			</h:panelGrid>
			<br />
			
		<h:panelGrid>
			<h:form>
				<h:outputLabel value="Ta bort användare" ></h:outputLabel>
				<h:selectOneMenu value="#{adminBean.selectedUser}">
	   			<f:selectItems value="#{adminBean.favUser2Value}" />
	   			</h:selectOneMenu>	   		
				<h:commandButton value="Ta bort" actionListener="#{adminBean.uppdateDBuser}" />
			</h:form>
		</h:panelGrid>
			
			<br />
		<h:panelGrid >
			<h:form>
	      			<h:outputLabel value="Username " ></h:outputLabel>
    	  			<h:inputText  value="#{adminBean.usname}"></h:inputText>
    	  			<br />
    	  			<h:outputLabel value="Password " ></h:outputLabel>
					<h:inputSecret  value="#{adminBean.password}"></h:inputSecret>
					<br />
					<h:outputLabel value="email adress " ></h:outputLabel>
					<h:inputText  value="#{adminBean.email}"></h:inputText>
					<br />
					<h:outputLabel value="Full name " ></h:outputLabel>
					<h:inputText  value="#{adminBean.name}"></h:inputText>
					<br />
					<h:commandButton actionListener="#{adminBean.addUser}" value="Lägg till användare"> 
						
					</h:commandButton>
			</h:form>
		</h:panelGrid>
			<br />
		<h:panelGrid>
			<h:form>
	      			<h:outputLabel value="Image URL " ></h:outputLabel>
    	  			<h:inputText  value="#{adminBean.imgURL}"></h:inputText>
    	  			<br />
    	  			<h:outputLabel value="Product name " ></h:outputLabel>
					<h:inputText  value="#{adminBean.pname}"></h:inputText>
					<br />
					<h:outputLabel value="Product info " ></h:outputLabel>
					<h:inputText  value="#{adminBean.info}"></h:inputText>
					<br />
					<h:outputLabel value="Price " ></h:outputLabel>
					<h:inputText  value="#{adminBean.price}"></h:inputText>
					<br />
					<h:outputLabel value="Quantity " ></h:outputLabel>
					<h:inputText  value="#{adminBean.quantity}"></h:inputText>
					<br />
					<h:outputLabel value="Category " ></h:outputLabel>
					<h:selectOneRadio value="#{adminBean.category}">
						<f:selectItem itemValue="mat" itemLabel="Mat" />
  				 		<f:selectItem itemValue="annat" itemLabel="Annat" />
					</h:selectOneRadio>
					<br />
					<h:commandButton actionListener="#{adminBean.addProduct}" value="Lägg till Produkt"></h:commandButton>
			</h:form>
		</h:panelGrid>
			  
			
			
			
			
		</h:panelGroup>
		
		
	</f:view>
</ui:insert>

</ui:composition>